package com.atlzk.seckill.seckill.utils;

import com.atlzk.group.tgou.entity.ResultMsg;
import com.atlzk.seckill.seckill.entity.SeckillMessage;
import com.atlzk.seckill.seckill.service.impl.SorderServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author King
 * @date 2021/7/1 - 9:01
 */
@Service
@Slf4j
public class SeckillMQLister {

    @Autowired
    private SorderServiceImpl sorderService;

    @RabbitListener(queues = MQConfig.SECKILL_QUEUE)
    public void seckillMQLister(SeckillMessage message) {
        log.info(message.toString());
        ResultMsg resultMsg = sorderService.seckill_logic(message.getUserId(), message.getSeckillId());
        System.out.println("=======================================================");
        log.info(resultMsg.toString());

    }
}
